﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SeaBattle.Domain.Abstract.Services;
using SeaBattle.Domain.Entities;
using SeaBattle.Domain.Abstract;

namespace SeaBattle.Domain.Concrete.Services
{
    public class FakePlayerService:IPlayerService
    {

        private IPlayerRepository playerRepository;

        public FakePlayerService(IPlayerRepository playerRepository)
        {
            this.playerRepository = playerRepository;
        }

        public bool PlayerExists(string name)
        {
            return playerRepository.GetAllPlayers().ToList().Exists(x=>x.Name ==name);
        }

        public void RegisterNewPlayer(Player player)
        {
            playerRepository.SavePlayer(player);
        }

        public Player GetPlayer(string login)
        {
            return playerRepository.GetPlayer(login);
        }

        public Player GetPlayer(int id)
        {
            return playerRepository.GetPlayer(id);
        }
    }
}
